//
//  WFCustomizeCandidateMenuSearchView.m
//  WeiFang
//
//  Created by WeiFang Team on 2022.
//  Copyright © 2022 WeiFang Team. All rights reserved.
//

#import "WFCustomizeCandidateMenuSearchView.h"
#import <objc/runtime.h>

@implementation WFCustomizeCandidateMenuSearchView

+ (id)instanceView {
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    return [nibView objectAtIndex:0];
}

- (void)awakeFromNib {
    // Initialization code
    [super awakeFromNib];
    _myTextField.delegate = self;
    _myTextField.clearButtonMode = UITextFieldViewModeWhileEditing;
    
    Ivar ivar = class_getInstanceVariable([UITextField class],"_placeholderLabel");
    UILabel *placeholderLabel = object_getIvar(_myTextField, ivar);
    placeholderLabel.textColor = UIColorFromHex(0x666666);
    placeholderLabel.font = [UIFont systemFontOfSize:13];
}
    
- (void)setData:(id)data delegate:(id)delegate {
    _delegate  = delegate;
    
    if ([data isKindOfClass:[WFCustomizeCandidateMenuSearchViewModel class]]) {
        WFCustomizeCandidateMenuSearchViewModel *model = data;
    }
}

- (IBAction)buttonAction:(UIButton *)sender {

    if (_delegate && [_delegate respondsToSelector:@selector(customizeCandidateMenuSearchView:buttonAction:)]) {
        [_delegate customizeCandidateMenuSearchView:self buttonAction:sender];
    }
}

- (IBAction)editingDidBeginButtonAction:(UITextField *)sender {

}

- (IBAction)editingChangedButtonAction:(UITextField *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(customizeCandidateMenuSearchView:buttonAction:)]) {
        [_delegate customizeCandidateMenuSearchView:self buttonAction:sender];
    }
}

@end


@implementation WFCustomizeCandidateMenuSearchViewModel

+ (WFCustomizeCandidateMenuSearchViewModel *)ittemModelWithIsEdit:(BOOL)isEdit {
    WFCustomizeCandidateMenuSearchViewModel *model = [WFCustomizeCandidateMenuSearchViewModel new];
    model.isEdit = isEdit;
    return model;
}

@end
